home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Graphics⁄Sound / Fudd Source / Fudd ƒ / MSG Shell ƒ / msg environment.c < prev    next >
Text File  |  1994-02-07  |  3KB  |  108 lines

  1. /**********************************************************************\
  2.  
  3. File:        msg environment.c
  4.  
  5. Purpose:    This module handles initializing the environment and
  6.             checking for various environmental characteristics.
  7.  
  8.  
  9. Fudd -=- convert text to Elmer Fudd talk
  10. Copyright ©1994, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "GestaltEqu.h"
  30. #include "msg environment.h"
  31. #include "msg apple events.h"
  32. #include "msg graphics.h"
  33. #include "msg menus.h"
  34. #include "program globals.h"
  35.  
  36. Boolean            gHasColorQD;
  37. Boolean            gHasAppleEvents;
  38. Boolean            gHasFSSpecs;
  39. Boolean            gStandardFile58;
  40. Boolean            gHasPowerManager;
  41.  
  42. Boolean            gIsInBackground;
  43. Boolean            gInProgress;
  44. Boolean            gDone;
  45. Boolean            gDisableQuit;
  46.  
  47. Rect            gDragRect;
  48. Rect            gSizeRect;
  49.  
  50. void CheckEnvironment(void)
  51. {
  52.     long    gestalt_temp;
  53.     OSErr    isHuman;
  54.     
  55.     isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  56.     gHasColorQD = !(isHuman || (gestalt_temp < gestalt8BitQD));
  57.     
  58.     GetMainScreenBounds();
  59.     
  60.     isHuman = Gestalt(gestaltFSAttr, &gestalt_temp);
  61.     gHasFSSpecs=((isHuman==noErr) && (gestalt_temp & (1 << gestaltHasFSSpecCalls)));
  62.  
  63.     isHuman=Gestalt(gestaltPowerMgrAttr, &gestalt_temp);
  64.     gHasPowerManager=((!isHuman) && (gestalt_temp&(1<<gestaltPMgrCPUIdle)));
  65.     
  66.     gHasAppleEvents=0;
  67.     isHuman = Gestalt(gestaltAppleEventsAttr, &gestalt_temp);
  68.     if(!isHuman)
  69.     {
  70.         gHasAppleEvents = 1;
  71.         SetUpAppleEvents();
  72.     }
  73. }
  74.  
  75. void InitEnvironment(void)
  76. {
  77.     Handle        MBARHandle;
  78.     int            i;
  79.     
  80.     MBARHandle = GetNewMBar(400);
  81.     SetMenuBar(MBARHandle);
  82.     gAppleMenu = GetMHandle(appleMenu);
  83.     gFileMenu = GetMHandle(fileMenu);
  84.     gEditMenu = GetMHandle(editMenu);
  85.     gOptionsMenu = GetMHandle(optionsMenu);
  86.     
  87.     gHelpMenu = GetMenu(helpMenu);
  88.     InsertMenu(gHelpMenu, -1);
  89.     
  90.     AddResMenu(gAppleMenu, 'DRVR');
  91.     
  92.     gInProgress=FALSE;
  93.     
  94.     AdjustMenus();
  95.     DrawMenuBar();
  96.     
  97.     gNumHelp=CountMItems(gHelpMenu);
  98.     
  99.     gDragRect = screenBits.bounds;
  100.     gDragRect.top += 4;
  101.     gDragRect.left += 4;
  102.     gDragRect.right -= 4;
  103.     gDragRect.bottom -= 4;
  104.     
  105.     gDone=FALSE;
  106.     gIsInBackground=FALSE;
  107. }
  108.